package com.wf.day_0608.test1;

/**
 * @author mpk
 * @since 2024/6/8 20:44:35
 */
public class Ticket extends  Thread{


   static int ticket  =1000;

    @Override
    public void run() {

        while (true)
        {
            synchronized (Ticket.class) {
                if (ticket == 0) {
                    break;
                } else {
                    try {
                        Thread.sleep(100);
                        System.out.println(Thread.currentThread().getName() + "卖出第" + ticket-- + "张票");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }


        }

    }
}
